<?php
namespace App\Services\Fund\FundRefundLog;
use App\Services\Fund\ValidateFundRefundLog;
use App\Models\Fund\FundRefundLog;
use Illuminate\Support\Facades\DB;
class FundRefundLogLogic
{
    // 所有用户资金还款日志分页数据
    public function list(array $data): array
    {
        $where['status'] = 1;
        $res = FundRefundLog::where($where)
                     ->orderBy('id', 'desc')
                     ->paginate($data['list_rows'], null, null, $data['page'])
                     ->toArray();
        return auto_return_page($res, '已找到用户资金还款日志', '没有用户资金还款日志');
    }
    // 获取某些user_ids的的资金还款日志(分页)
    public function listByUserIds(array $data): array
    {
        $where['status'] = 1;
        $res = FundRefundLog::where($where)
                     ->whereIn('user_id',[$data['user_ids']])
                     ->orderBy('id', 'desc')
                     ->paginate($data['list_rows'], null, null, $data['page'])
                     ->toArray();
        return auto_return_page($res, '已找到用户资金还款日志', '没有用户资金还款日志');
    }
    // 获取某个借款日志的资金还款日志
    public function listByBorrowId(array $data): array
    {
         $res = FundRefundLog::where([['status','=',1],['borrow_log_id','=',$data['borrow_log_id']]])
                     ->orderBy('id', 'desc')
                     ->paginate($data['list_rows'], null, null, $data['page'])
                     ->toArray();            
        return auto_return_page($res, '已找到资金还款日志', '没有资金还款日志');
    }
}